<script type="text/javascript" src="{$base_dir}modules/general_emr/js/AJAX_General_Examination.js"></script>

{literal}
<script type="text/javascript">
$(document).ready(function() {
    // Register Autocomplete for doctor name
    var doctorAC = $('#doctorName').autocomplete('../Employee/GetDoctorAutoCompleteAjax?set_ajax_view');
    doctorAC.setOptions({
        width:          195,
        minChars:       2,
        formatItem:     formatMatch                                                                                                             
    }); 

    // Fill data for doctor name autocomplete result
    $('#doctorName').result(function(event, data, formatted) {
        $(this).val(data[0]);
        $('#doctorId').val(data[2]);    
    }); 

 // Format data result for service code autocomplete
    function formatMatch(item) {        
        return item[0] + '<br /><i>' + item[1] + '</i>';
    }
});   
</script>
{/literal}

    <form id="frmClinDiagEdit" action="../GeneralExamination/EditGeneralExamination" method="post">
        <input type="hidden" name="encounterId" id="encounterId" value="{$encounter->get_id()}">
        <input type="hidden" name="recordId" id="recordId" value="{$recordId}">
        <span id="statusMessageClinDiag" class='formAlertMsg'></span><br/>
        
        <div style='border: 1px solid #BBB; padding: 0px 0px; -moz-box-shadow:0 0 3px #AAA; -webkit-box-shadow:0 0 3px #AAA;'>
            <div class='field-row add-patient-row'>
                <div class='field-label add-patient-label' style='width: 120px;'>{translate}Doctor{/translate} *</div>                 
                <div class='field-label' style='width: 350px; height: 35px; line-height: 35px;'>
                    <input id="doctorId" type="hidden" name="emr[doctor_id]" value="{$doctorId}">
                    <input id="doctorName" name="doctorName" type="text" value="{$doctorName}" style="width: 250px;" onkeyup="return moveNext(event, 'medicalHistory')">
                    &nbsp;                                  
                </div>                                   
                
                <div class='field-label add-patient-label' style='width: 120px;'>{translate}Latest update{/translate}</div>
                <div class='field-value add-patient-value' style='width: 350px;'>                    
                    {$updatedDate}                    
                </div>
                   
                <div style='clear: both;'></div>
            </div>
            
            <div class='field-row add-patient-row'>
                <div class='field-label add-patient-label' style='width: 120px;'>{translate}Medical history{/translate}</div>
                <div class='field-value add-patient-value' style='width: 350px;'>
                    <textarea name="emr[medical_history]" id="medicalHistory" rows="1" cols="45">{$encounter->get('medical_history')}</textarea>                    
                    &nbsp;                    
                </div>                          
                
                <div class='field-label add-patient-label' style='width: 120px;'>{translate}Allergy{/translate}</div>
                <div class='field-value add-patient-value' style='width: 350px;'>
                    <textarea name="emr[allergy]" rows="1" cols="45">{$encounter->get('allergy')}</textarea>                    
                    &nbsp;                    
                </div>
               <div style='clear: both;'></div>
            </div>
            
             <div class='field-row add-patient-row'>
                <div class='field-label add-patient-label' style='width: 120px;'>{translate}Symptom{/translate}</div>
                <div class='field-value add-patient-value' style='width: 350px;'>
                    <textarea name="emr[symptom]" rows="1" cols="45">{$encounter->get('symptom')}</textarea>                    
                    &nbsp;                    
                </div>  
                                       
                
                <div class='field-label add-patient-label' style='width: 120px;'>{translate}Diagnosis{/translate}</div>
                <div class='field-value add-patient-value' style='width: 350px;'>
                    <textarea  name="emr[diagnosis]" rows="1" cols="45">{$encounter->get('diagnosis')}</textarea>                    
                    &nbsp;                    
                </div>  
                <div style='clear: both;'></div>
            </div>
                       
            
            <!-- Note & ICD -->
             <div class='field-row add-patient-row'>                                           
                <div class='field-label add-patient-label' style='width: 120px;'>{translate}Note{/translate}</div>
                <div class='field-value add-patient-value' style='width: 350px;'>
                   <textarea name="emr[note]" id="clinDiagNote" rows="1" cols="45">{$encounter->get('note')}</textarea>           
                </div>  
                
                <div class='field-label add-patient-label' style='width: 120px;'>{translate}ICD diagnosis{/translate}</div>
                <div class='field-value add-patient-value' style='width: 350px;'>
                    <input type="text" name="emr[primary_icd10]" id="clinDiagPrimaryIcd10" value="{$priIcd10->getCode()}" align="left" size="7">
                    <input type="text" name="clinDiagPrimaryDiagnosis" id="clinDiagPrimaryDiagnosis" value="{$priIcd10->getLocalizedText('name')}" align="left" size="45">
                    <button type="button" id="btnPriIcd10">...</button>                   
                </div>
                
                <div style='clear: both;'></div>
            </div>
            
            {if ($enableSecondary)} 
             <div class='field-row add-patient-row'>                                           
                <div class='field-label add-patient-label' style='width: 120px;'>{translate p='1'}Auxiliary diagnosis %s{/translate}</div>
                <div class='field-value add-patient-value' style='width: 550px;'>
                     <input type="text" name="emr[secondary_icd10_1]" id="clinDiagSecondaryIcd10_1" value="{$sec1Icd10->getCode()}" align="left" size="10">
                    <input type="text" name="clinDiagSecondaryDiagnosis_1" id="clinDiagSecondaryDiagnosis_1" value="{$sec1Icd10->getLocalizedText('name')}" align="left" size="45">
                    <button type="button" id="btnSecIcd10_1">...</button>                
                </div>  
                <div style='clear: both;'></div>
            </div>
            
            <div class='field-row add-patient-row'>                                           
                <div class='field-label add-patient-label' style='width: 120px;'>{translate p='2'}Auxiliary diagnosis %s{/translate}</div>
                <div class='field-value add-patient-value' style='width: 550px;'>
                    <input type="text" name="emr[secondary_icd10_2]" id="clinDiagSecondaryIcd10_2" value="{$sec2Icd10->getCode()}" align="left" size="10">    
                    <input type="text" name="clinDiagSecondaryDiagnosis_2" id="clinDiagSecondaryDiagnosis_2" value="{$sec2Icd10->getLocalizedText('name')}" align="left" size="45">
                    <button type="button" id="btnSecIcd10_2">...</button>             
                </div>  
                <div style='clear: both;'></div>
            </div>
            {/if}                        
        </div>
        
        
        <div style="margin-top: 20px; text-align: right;">
            <span id="lblEditMessage" style='font-style: italic'></span> 
            <input type="button" id="btnSave" style="width: 80px;" onclick="javascript:submitForm()" value="{translate}Save{/translate}"></input>                
            <!-- 
            <a id="btnSave" class="button_link" href="javascript:submitForm()">{translate}Save{/translate}</a>
             -->
            <div id='module-loading' class='module-loading' style="width: 100px; display: none;"></div>
        </div>

        <table border="0" cellpadding="0" cellspacing="0">                      
            <tr>
                
                <td colspan='3' align='left'>
                    
                </td>
            </tr>
        </table>
    </form>
    {include file="icd_10/element_icd10_selector.html"}
